<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use frontend\models\ArtForm;
use kartik\file\FileInput;

/* @var $this yii\web\View */
/* @var $model common\models\Art\Art */
/* @var $form yii\widgets\ActiveForm */
?>
<style>
.kv-file-content img{ width: 100%!important; }
</style>
<div class="art-form">

    <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data'], 'id' => 'subform']); ?>

    <?= $form->field($model, 'title')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'intro')->textarea(['rows' => 6]) ?>

        <?php
            if(isset(json_decode($model->img)->newname)){
                $img = json_decode($model->img)->newname;
            }else{

                $img = $model->img;
            }

            $siteRoot = Yii::$app->params['qtimg'];
            echo '<label class="control-label">图片</label>;';
            echo FileInput::widget([
                'model' => $model,
                'attribute' => 'img',
                'options' => ['accept' => 'image/*'],
                'pluginOptions' => [
                    'uploadExtraData' => [
                        'album_id' => 20,
                        'cat_id' => 'Nature'
                    ],
                    'initialPreview'=>[
                        !empty($img)?Html::img(Yii::$app->params['qtimg'].$img):null,
                    ],
                    'initialCaption'=> $img,
                    'maxFileCount' => 10,
                    "showUpload"=> false,
                ]
            ]);
        ?>


    <?= $form->field($model, 'reason')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'link')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model,'content')->widget('kucha\ueditor\UEditor',[]); ?>

    <?= $form->field($model, 'seocontent')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'seokeyword')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'display')->dropDownList(ArtForm::getArrayDis()) ?>

    <?= $form->field($model, 'status')->dropDownList(ArtForm::getArrayStatus()) ?>

    <!--?= $form->field($model, 'created_at')->textInput() ?-->

    <!--?= $form->field($model, 'updated_at')->textInput() ?-->

    <?= $form->field($model, 'member_id')->dropDownList(ArtForm::getArrayName()) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
